home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CRYP60.ZIP / CRYUHELP.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-15  |  7KB  |  257 lines

  1. {Start of file CryUHelp.Pas ************************************************}
  2.  
  3. unit CryUHelp; {Help unit for Variable Precision floating decimal calculator}
  4.  
  5. {$I-} {Do our own i/o error checks}
  6. {$N+} {Uses numeric coprocessor}
  7. {$R-} {No index Range checking}
  8. {$V-} {No string length checking}
  9.  
  10. interface
  11.  
  12. {***************************************************************************}
  13. const
  14.  Name  = 'CryU - A data encryption system written in Pascal, user interface';
  15.  Version = 'Version 6.00, 1992-11-15, 1400 hours';
  16.  Author  = 'Copyright (c) 1987-1992 by author: Harry J. Smith';
  17.  Address = '19628 Via Monte Dr., Saratoga, CA 95070.  All rights reserved.';
  18.  
  19. { Actual Name, Version, Author, Address maintained here. }
  20.  
  21. {***************************************************************************}
  22.  
  23. {Developed in TURBO Pascal 5.5, maintained in 6.0}
  24.  
  25. {The following PROCEDUREs can be called externally:}
  26.  
  27.   procedure HotHelp(I : Integer);      {Hot help for F1, F5..F10}
  28.   procedure CryUHotHelp(I : Integer);  {Hot help for F1, ..., F10}
  29.   procedure Ind( N : Integer; St : String);    {Indent N}
  30.   procedure IndLn( N : Integer; St : String);  {Indent N & new line}
  31.   procedure Title;  {Output program's title messages}
  32.  
  33. implementation
  34.  
  35. uses
  36.   Crt,     { Turbo Pascal interface }
  37.   Prompt;
  38.  
  39. const
  40.   UL = Char( 201);  UR = Char( 187);  {Characters for drawing a box, ╔ ╗}
  41.   VB = Char( 186);  HB = Char( 205);  {║ ═}
  42.   LL = Char( 200);  LR = Char( 188);  { ╚ ╝}
  43.  
  44. var
  45.   Ch   : Char;
  46.   i, j : Integer;
  47.  
  48. {--------------------------------------}
  49. procedure Center( St : String);
  50. var
  51.   I : Integer;
  52. begin
  53.   for I:= 1 to (80 - Length( St)) div 2 do
  54.     Write(' ');
  55.   Write( St);
  56. end; {Center}
  57.  
  58. {--------------------------------------}
  59. procedure CenterLn( St : String);
  60. begin
  61.   Center( St);
  62.   WriteLn;
  63. end; {Center}
  64.  
  65. {--------------------------------------}
  66. procedure TopBox( First, Last : Integer);  {Draw top of a box}
  67. var
  68.   I : Integer;
  69. begin
  70.   for I:= 2 to First do  Write(' ');
  71.   Write( UL);
  72.   for I:= First to Last - 2 do  Write( HB);
  73.   WriteLn( UR);
  74. end; {TopBox}
  75.  
  76. {--------------------------------------}
  77. procedure CenterBox( First, Last : Integer; St : String);
  78.  {Draw center lines of a box}
  79. var
  80.   I : Integer;
  81. begin
  82.   for I:= 2 to First do  Write(' ');
  83.   Write( VB);
  84.   for I:= 1 to (Last - First - Length( St)) div 2 do  Write(' ');
  85.   Write( St);
  86.   for I:= 1 to (Last - First - Length( St) - 1) div 2 do  Write(' ');
  87.   WriteLn( VB);
  88. end; {CenterBox}
  89.  
  90. {--------------------------------------}
  91. procedure BotBox( First, Last : Integer);  {Draw bottom of a box}
  92. var
  93.   I : Integer;
  94. begin
  95.   for I:= 2 to First do  Write(' ');
  96.   Write( LL);
  97.   for I:= First to Last - 2 do  Write( HB);
  98.   Write( LR);
  99. end; {BotBox}
  100.  
  101. {--------------------------------------}
  102. procedure Title;  {Output program's title messages}
  103. begin
  104.   TopBox(6, 74);
  105.   CenterBox(6, 74, Name);
  106.   CenterBox(6, 74, Version);
  107.   CenterBox(6, 74, Author);
  108.   CenterBox(6, 74, Address);
  109.   BotBox(6, 74);
  110.   Write;
  111. end; {Title}
  112.  
  113. {--------------------------------------}
  114. procedure Ind( N : Integer; St : String);  {Indent N}
  115. var
  116.   I : Integer;
  117. begin
  118.   for I:= 1 to N do  Write(' ');
  119.   Write( St);
  120. end; {Ind}
  121.  
  122. {--------------------------------------}
  123. procedure IndLn( N : Integer; St : String);  {Indent N & new line}
  124. begin
  125.   Ind(N, St);
  126.   WriteLn;
  127. end; {IndLn}
  128.  
  129. {--------------------------------------}
  130. procedure DoBorder( X1, Y1, X2, Y2 : Byte; Title : String);  {Draw a border}
  131. var
  132.   I : Integer;
  133. begin
  134.   GoToXY( X1, Y1);
  135.   TopBox( 1, X2 - X1 + 1);
  136.   GoToXy( (X1 + X2 - Length( Title)) div 2, Y1);
  137.   Write( Title);
  138.   for I:= Y1+1 to Y2-1 do begin
  139.     GoToXY( X1, I);  Write( VB);
  140.     GoToXY( X2, I);  Write( VB);
  141.   end;
  142.   GoToXY( X1, Y2);
  143.   BotBox( 1, X2 - X1 + 1);
  144.   Window( X1+1, Y1+1, X2-1, Y2-1);
  145.   ClrScr;
  146. end; {DoBorder}
  147.  
  148. {--------------------------------------}
  149. procedure F1;  {Hot help for F1}
  150. var
  151.   TextAttr1 : Byte;
  152.   WindMin1  : Word;
  153.   WindMax1  : Word;
  154. begin
  155.   TextAttr1:= TextAttr;
  156.   WindMin1:= WindMin;
  157.   WindMax1:= WindMax;
  158.   TextBackground( Cyan);
  159.   TextColor( White);
  160.   DoBorder( 15, 7, 65, 14, ' Help ');
  161.   GoToXY(1, 1);
  162.   TextColor( Black);
  163.   IndLn(3, 'F1  => This help menu');
  164.   IndLn(3, 'F2  => Quit and exit to operating system*');
  165.   IndLn(3, 'F3  => Restore previous input*');
  166.   IndLn(3, 'F4  => Restore previous input and accept*');
  167.   IndLn(3, 'F5  => Active control characters for editing');
  168.   Ind(  3, 'ESC => Exit Help (* active on Command: line)');
  169.   TextAttr:= TextAttr1;
  170.   WindMin:= WindMin1;
  171.   WindMax:= WindMax1;
  172.   GoToXY( 65, 14);
  173. end; {F1}
  174.  
  175. {--------------------------------------}
  176. procedure CryUHotHelp(I : Integer);  {Hot help for F1, ..., F10}
  177. var
  178.   done : boolean;
  179.   Ch   : char;
  180. begin
  181.   HotKey:= False;
  182.   if (I = 59) or ((63 <= I) and (I <= 63)) then begin
  183.     HotKey:= True;  done:= False;
  184.     repeat
  185.       if      (I = 59) then  F1
  186.       else if (I = 63) then  HelpProm  {F5}
  187.       else  I:= 0;
  188.       if (I <> 0) and (I >= 63) then begin
  189.         Center(' >>>> PRESS ESC TO EXIT HELP <<<< ');
  190.       end;
  191.       I:= 0;
  192.       Ch:= ReadKey;
  193.       if Ch = Chr(0) then begin
  194.         I:= Ord( ReadKey);
  195.       end
  196.       else begin
  197.         if (Ch = Chr( 27)) then  done:= True;  {ESC}
  198.       end;
  199.     until done;
  200.   end;
  201. end; {CryUHotHelp}
  202.  
  203. {--------------------------------------}
  204. procedure HotHelp(I : Integer);  {Hot help for F1, F5..F10}
  205. var
  206.   done : boolean;
  207.   TextAttr1 : Byte;
  208.   WindMin1  : Word;
  209.   WindMax1  : Word;
  210. begin
  211.   TextAttr1:= TextAttr;
  212.   WindMin1:= WindMin;
  213.   WindMax1:= WindMax;
  214.   Screen1^:= Screen^;
  215.   Screen1^.CursX:= WhereX;
  216.   Screen1^.CursY:= WhereY;
  217.   CryUHotHelp(I);
  218.   Screen^:= Screen1^;
  219.   TextAttr:= TextAttr1;
  220.   WindMin:= WindMin1;
  221.   WindMax:= WindMax1;
  222.   GoToXY( Screen1^.CursX, Screen1^.CursY);
  223. end; {HotHelp}
  224.  
  225. {--------------------------------------}
  226. function ExitHelp: Boolean;  {Test for exit help}
  227. const Echo = 0;
  228. var
  229.   I : Integer;  Ch : Char;
  230. begin
  231.   ExitHelp:= True;
  232.   for I:= Echo downto 0 do begin
  233.     Center(' **** PRESS ANY KEY TO CONTINUE HELP OR PRESS ESCAPE **** ');
  234.     Ch:= ReadKeyM( HotHelp);
  235.     WriteLn;
  236.     if Ch = Char( 27) then begin {Esc}
  237.       for I:= Echo downto 0 do  WriteLn;
  238.       Exit;
  239.     end;
  240.     ClrScr;
  241.     WriteLn;
  242.   end;
  243.   ExitHelp:= False;
  244. end; {ExitHelp}
  245.  
  246. {--------------------------------------}
  247. begin  {Init the unit}
  248.   ;
  249. end.
  250.  
  251. Revisions made -
  252. --------
  253.  
  254. --------
  255.  
  256. {End of file CryUHelp.Pas **************************************************}
  257.